Release 10.1A: OpenEdge Development:
Programming Interfaces
Sending output to multiple destinations
At some points in a procedure, you might want to send output to the terminal, but at other points you might want to send output to a file. Progress does not restrict you to one output destination per procedure.
Figure 5–4: Multiple output destinations
![]()
In the procedure in Figure 5–4, you supply the name of the file where you want to send a customer report and then, if that file does not already exist, send the report to that file.
![]()
To send output to a file:
- The
SETstatement prompts you for the filename.- The
SEARCHfunction searches for the file, returning the filename if the file is found.- If the file is found, the procedure:
- If the file is not found, the procedure uses this statement:
This statement redirects the output to the file you specified. You must use the
VALUEkeyword with theOUTPUTTOstatement. TheVALUEoption tells Progress to use the value of the outfile variable rather than the name “outfile” itself. If instead you sayOUTPUTTOoutfile, Progress assumes that outfile is the name of the text file to which you want to send output.You use the
OUTPUTCLOSEstatement to stop sending output to a destination. Output sent after theOUTPUTCLOSEstatement goes to the destination used prior to theOUTPUTTOstatement.For example, the procedure in Figure 5–5 uses the
OUTPUTCLOSEstatement to reset the output destination from a file to the terminal.Figure 5–5: The OUTPUT CLOSE statement
![]()
This procedure sends customer information to a file called
cust.dat. Then the procedure displays the word “Finished” on your terminal screen. The procedure executes as follows:
- The
OUTPUTTOstatement redirects output so all statements that normally send output to the terminal send output to thecust.datfile.- The
FOREACH customerandDISPLAYstatements produce a report listing each customer’s name, address, city, and state. The procedure sends the report to thecust.datfile.- The
OUTPUTCLOSEstatement resets the output destination for the procedure from thecust.datfile to the terminal.- The last
DISPLAYstatement displays the message “Finished” on the terminal screen.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |